# Contributor: wener <wenermail@gmail.com>
# Maintainer: lauren n. liberda <lauren@selfisekai.rocks>
pkgname=sqlcipher
pkgver=4.5.6
pkgrel=1
pkgdesc="SQLCipher is an SQLite extension that provides 256 bit AES encryption of database files."
url="https://www.zetetic.net/sqlcipher/"
arch="all"
license="BSD-3-Clause"
makedepends="openssl-dev>3 tcl-dev readline-dev zlib-dev"
subpackages="
	$pkgname-dbg
	$pkgname-dev
	$pkgname-doc
	$pkgname-libs
	$pkgname-tcl
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/sqlcipher/sqlcipher/archive/v$pkgver.tar.gz"

build() {
	export CFLAGS="$CFLAGS \
		-DSQLITE_HAS_CODEC \
		-DSQLCIPHER_TEST \
		-DSQLITE_ENABLE_COLUMN_METADATA \
		-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
		-DSQLITE_ENABLE_FTS3_PARENTHESIS \
		-DSQLITE_SECURE_DELETE \
		-DSQLITE_ENABLE_UNLOCK_NOTIFY \
		-DSQLITE_ENABLE_RTREE \
		-DSQLITE_ENABLE_GEOPOLY \
		-DSQLITE_USE_URI \
		-DSQLITE_ENABLE_DBSTAT_VTAB \
		-DSQLITE_MAX_VARIABLE_NUMBER=250000 \
		"
	export LDFLAGS="$LDFLAGS -lcrypto"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tempstore=yes \
		--enable-fts5

	make
}

check() {
	make testfixture
	./testfixture test/sqlcipher.test
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm0644 sqlcipher.1 \
		"$pkgdir"/usr/share/man/man1/sqlcipher.1
}

tcl() {
	pkgdesc="SQLCipher library (tcl bindings)"

	amove usr/lib/tcl*
}

sha512sums="
656206cd6f8eaec15a8c409c47c1c2ca7fa3d30f3b124f89ceeff3c0c8772e0b3cc942ef93a18a4ce4dee12b1d9bd94d7e4132cea35707871fe8c08b13f87797  sqlcipher-4.5.6.tar.gz
"
